var reg = /^[a-z0-9]{6,16}$/
var reg1 = /^[a-z0-9]+(@[a-z0-9]{1,10}\.com)$/
$("input").last().on("click", function (result) {
	if (reg.test($("#password").val())) {
		//判断密码和确认密码是否一致
		if ($("#password").val() == $("#password1").val()) {
			if (reg1.test($("input")[4].value)) {
				//注册请求
				registerUP();
			}else{
				BOX("red", "输入正确邮箱地址")
			}


		} else {
			BOX("red", "密码输入不一致")
		}
	} else {
		BOX("red", "密码只能包涵字母和数字")
	}

})
function registerUP() {
	AJAX("POST", Burl.register, {
		"name": $("input")[0].value,
		"username": $("input")[1].value,
		"password": $("input")[2].value,
		"email": $("input")[4].value,
		"phone": $("input")[5].value
	},
		function (result) {
			if (result.data.created == true) {
				sessionStorage.setItem("usere", result.data.username)//保存注册的账号
				window.location.href = "./login.html"
			} else {
				BOX("red", "注册失败")
			}
		}
	)
}
